package com.gugee.ins.web.controller;

import com.gugee.common.web.util.Ret;
import com.gugee.common.web.config.exception.ParamsException;
import com.gugee.ins.web.dto.InsBloggerSearchData;
import com.gugee.ins.web.service.InsBloggerService;
import com.gugee.common.web.system.promise.Limit;
import com.gugee.common.web.system.promise.RequestLimit;
import com.gugee.common.web.system.user.log.Operation;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;

@RestController
@Api(value = "ins博主",tags = {"ins博主"})
public class InsBloggerController extends InsBaseController {

    @Autowired
    InsBloggerService insBloggerService;

    @ApiOperation(value = "获取INS博主列表")
    @RequestMapping(value = "blogger",method = RequestMethod.GET,produces = "application/json;charset=UTF-8")
    @RequestLimit(value = "InsSearchPageLimit",property = "page,pageSize",validateType = Limit.VIEW_DATA_LIMIT)
    @Operation(value = "获取INS博主列表")
    public String getBlogger(String data) throws UnsupportedEncodingException, ParamsException {
        InsBloggerSearchData searchData = getParam(InsBloggerSearchData.class, URLDecoder.decode(data,"UTF-8"));
        return Ret.success("OK",insBloggerService.getPageByEs(searchData));
    }
}
